<div class="container">

    <div class="row">

        <div class="span2">
            <?php
            $menu = 'menu_' . $this->usertype . '.php';
            include($menu);
            ?>
        </div>



        <div class="span10">
            <script>
                $(function() {
                    $(".txshow").hide();
                })

                function addplace()
                {
                    $.each($('.select_space'), function() {
                        var id = $(this).attr('id');
                        var add = $("#" + id).val();
                        if (add == 'add')
                        {
                            $("#" + id + "2").show();
                        }
                        else
                        {
                            $("#" + id + "2").hide();
                        }
                    });
                }

                function remove_tag()
                {

                    $.each($('.select_space'), function() {
                        var id = $(this).attr('id');
                        var add = $("#" + id).val();
                        if (add != 'add')
                        {
                            $("#" + id + "2").remove();
                        }
                    });
                }

                function hide_current()
                {
                    $("#hide_current").toggle();

                }

            </script>
            <?php
            if (isset($patient)) {
                foreach ($patient as $key => $value) {
                    
                }
            } else {
                $value = false;
            }
            ?>

            <h3 class="topic">เพิ่มผู้ใช้บริการ</h3>
            <div class="well" style="min-height:250px;">

                <script>
                    jQuery(document).ready(function() {
                        // binds form submission and fields to the validation engine
                        jQuery("#formID").validationEngine();

                    });

                </script>

                <form  id="formID" method="post" name="add_patient" action="<?php echo base_url(); ?>staff/query_service/<?php echo $check_pat['check_id'] ?>" onsubmit="remove_tag();">
                    <fieldset>



                        <center>  
                            <div> 

                                <div class="control-group">
                                    <label for="title" class="control-label">ชือผู้ป่วย </label>
                                    <?php echo $patient['pat_name'] . '  ' . $patient['pat_lname']; ?>
                                    <input type="hidden" name="pat_id" value="<?php echo $patient['pat_id'] ?>" >
                                </div>     
                                <hr>
                                <div class="control-group">
                                    <label for="title" class="control-label " style="margin-right: 15px;">ขาที่ใช้บริการ </label>
                                    <input type="checkbox" <?php echo ($check_pat['neck_left']) == 1 ? 'checked' : ''; ?>  name="neck_left"  class="span"> ขาซ้าย
                                    <input type="checkbox" <?php echo ($check_pat['neck_right']) == 1 ? 'checked' : ''; ?>  name="neck_right"  class="span" > ขาขวา
                                </div>   

                                <div class="control-group span5 right">
                                    <label for="title" class="control-label " style="margin-right: 15px;">ณ </label>
                                    <select name="place" id="place" onchange="addplace();" class="select_space validate[required]">
                                        <option value="" > - <i class="icon-map-marker"></i>  เลือกสถานที่ - </option>
                                        <option value="add" > - <i class="icon-map-marker"></i>  เพิ่มสถานที่ - </option>

                                        <?php
                                        $i = 1;
                                        foreach ($place as $key_plc => $value_plc) {
                                            ?>
                                            <option value="<?php echo $value_plc['place']; ?>" <?php echo ($check_pat['place'] == $value_plc['place'] ? ' selected="selected" ' : '') ?> ><?php echo $value_plc['place']; ?></option>
                                            <?php
                                            $i++;
                                        }
                                        ?>
                                    </select>
                                    <input type="text" placeholder="พิมพ์ชื่อสถานที่" name="place" id="place2" class="txshow" >
                                </div>


                                <div class="control-group span4 left">
                                    <label for="title" class="control-label " style="margin-right: 15px;">วันที่ </label>
                                    <input type="date" value="<?php echo $check_pat['date'] ?>"  name="date" id="datepicker" class="validate[required]"> 
                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                </div>
                                <div class="control-group span5 right">
                                    <label for="title" class="control-label " style="margin-right: 15px;">สิทธิการรักษา </label>
                                    <select name="pat_right" id="pat_right" onchange="addplace();" class="select_space validate[required]">
                                        <option value="" > - <i class="icon-map-marker"></i>  เลือกสิทธิ์ - </option>

                                        <option value="add" > - <i class="icon-map-marker"></i>  เพิ่มสิทธิ์ - </option>

                                        <?php foreach ($pat_right as $key => $value) {
                                            ?>
                                            <option value="<?php echo $value['pat_right']; ?>"<?php echo ($check_pat['pat_right'] == $value['pat_right'] ? ' selected="selected" ' : '') ?>  ><?php echo $value['pat_right']; ?></option>
                                            <?php
                                        }
                                        ?>
                                    </select>
                                    <input type="text" placeholder="พิมพ์ชื่อสิทธิการรักษา" name="pat_right" id="pat_right2" class="txshow validate[required]">
                                </div>

                                <div class="control-group span4 left">
                                    <label for="title" class="control-label " style="margin-right: 15px;">จังหวัด </label>
                                    <select name="province" class="validate[required]">
                                        <?php
                                        if ($check_pat['province'] != '') {
                                            ?>
                                            <option value="<?php echo $check_pat['province'] ?>" selected ><?php echo $check_pat['province'] ?></option>
                                            <?php
                                        }
                                        ?>
                                        <?php include('province.php'); ?>
                                    </select>
                                </div>

                                </fieldset>
                                <center>
                                    <input class="btn btn-primary" type='submit' name="submit" value="บันทึก">
                                    <a class="btn btn-danger"  href="<?php echo base_url() ?>patient/list_pat_check" >ย้อนกลับ</a>
                                </center>
                                </form>
                        </center>



<!--                <script>
                  $(function() {
                        $("#datepicker").datepicker({
                            format: 'dd/mm/yyyy',
                            autoclose: true,
                            language: "th"
                        });
                        $("#datepicker").datepicker().next().on(ace.click_event, function() {
                            $(this).prev().focus();
                        });
                    })
                </script> -->
                        </div>


                        </div>





                        </div>
                        <hr>
                        <!--Start second row of columns-->

